home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The Arsenal Files 4
/
The Arsenal Files 4 (Arsenal Computer).ISO
/
casm
/
au116-as.exe
/
UTIL
/
FILELINE.CPP
< prev
next >
Wrap
C/C++ Source or Header
|
1994-05-22
|
2KB
|
75 lines
#include "..\au.hpp"
/* read_raw_line() gets a raw line from a text file
read_line() gets a .cfg file line from a text file */
/************************************************************************/
int HANDLE::read_raw_line(char *string)
{
int c, string_pos=0;
while ((c = read_char()) != EOF)
{
if (c=='\n' || c=='\r')
break;
string[string_pos++] = c;
}
if (string_pos==0 && c==EOF)
return EOF;
string[string_pos] = '\0';
return 0;
}
/************************************************************************/
/* get a line of text from a file trim the spaces on the left */
/* and remove comments */
/************************************************************************/
int HANDLE::read_line(AU *au, char *string)
{
int ret_code;
char *pos;
ret_code = read_raw_line(string);
pos = strchr(string, ';'); /* Remove comment */
if (pos != NULL)
*pos = '\0';
subst_environ(au, string);
if (string[0] == '\0' && ret_code == EOF)
return EOF;
ltrim(string);
return 0;
}
/************************************************************************/
/* get a word of text from a file trim the spaces on the left
and remove comments */
int HANDLE::read_word(char *string)
{
int c, string_pos=0;
while ((c = read_char()) != EOF)
{
if (!isspace(c))
break;
string[string_pos++] = c;
}
if (c==EOF)
return EOF;
string[string_pos++] = c;
while ((c = read_char())!=EOF)
{
if (isspace(c))
break;
string[string_pos++] = c;
}
string[string_pos] = '\0';
return 0;
}